home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000076_icon-group-sender _Tue Sep 23 08:01:38 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  4KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id IAA11882
  4.     for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Tue, 23 Sep 1997 08:01:37 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA09017; Tue, 23 Sep 1997 08:01:36 -0700
  7. To: icon-group@cs.arizona.edu
  8. Date: Tue, 23 Sep 1997 18:12:03 +1000
  9. From: Stuart.Robinson@anu.edu.au (Stuart Robinson)
  10. Message-Id: <Stuart.Robinson-2309971812040001@asianstmg-221.anu.edu.au>
  11. Organization: ANU
  12. Sender: icon-group-request@cs.arizona.edu
  13. Subject: another program with problems
  14. Errors-To: icon-group-errors@cs.arizona.edu
  15. Status: RO
  16.  
  17. Hello.  I'm sorry to keep posting my programs to comp.lang.icon for
  18. editorial comments, but I have no local Icon support.  Anyhow, I have a
  19. program that is producing output that I wouldn't expect, given the input. 
  20. Here's the program:
  21.  
  22. ################################################################################
  23. ## Program modified 22 Sept 1997, SPR--total_no added
  24. ## Program finished 13 May 97, SPR  
  25. ## program designed to tally the number of {S's, {A's, and {O's in a text
  26. ################################################################################
  27.  
  28. procedure main()
  29.  
  30. chars := &letters ++ &digits ++ '{.*[]?'     #valid characters
  31.  
  32. total_no := 0
  33. noS := 0
  34. noA := 0
  35. noO := 0
  36. none := 0
  37.  
  38. while line := read() do                   #line = line of text
  39.    {
  40.  
  41.    total_no +:= 1                      #increment total_no by 1
  42.    
  43.    line ?                              #scan line
  44.       {
  45.       while tab(upto(chars)) do           #look for valid character
  46.          {
  47.          word := tab(many(chars))         #word = valid character through
  48. next invalid character
  49.          word ?                        #scan word
  50.             {
  51.             while tab(upto("{") +1) do    #move just past bracket (will
  52. fail if there is none)
  53.                {
  54.                wordfrag := move(1)        #wordfrag = one character past bracket
  55.                
  56.                case wordfrag of        #if wordfrag is
  57.                   {
  58.  
  59.                   "S"   :  noS +:= 1      #S, then increment noS by 1
  60.                   "A"   :  noA +:= 1      #A, then increment noA by 1
  61.                   "O"   :  noO +:= 1      #O, then increment noO by 1
  62.                   default : none +:= 1    #none of the above letters, 
  63.                                           #then increment none by 1
  64.  
  65.                   }
  66.                }
  67.             }
  68.          }
  69.       }
  70.    }
  71.  
  72. write( "Total No. of Clauses: " || total_no )   #writes total number of
  73. clauses (total_no)
  74. write( "Total No. of Nonverbal Clauses: " || none )   #writes total number
  75. of clauses without S, A, or O
  76. write( "Total No. of S's: " || noS )         #writes total number of S's (noS)
  77. write( "Total No. of A's: " || noA )         #writes total number of A's (noA)
  78. write( "Total No. of O's: " || noO )         #writes total number of O's (noO)
  79.  
  80. end
  81.  
  82. ################################################################################
  83.  
  84. Here's the input:
  85.  
  86. {S
  87. {A
  88. {O
  89. {S
  90. {A
  91. {O
  92. {S
  93. {A
  94. {O
  95. nonverbal
  96. nonverbal
  97. nonverbal
  98. {
  99. {
  100. {
  101.  
  102.  
  103. Given the program and the input, I would expect the following output:
  104.  
  105. Total No. of Clauses: 15
  106. Total No. of Nonverbal Clauses: 3
  107. Total No. of S's: 3
  108. Total No. of A's: 3
  109. Total No. of O's: 3
  110.  
  111.  
  112. But instead I get this:
  113.  
  114. Total No. of Clauses: 15
  115. Total No. of Nonverbal Clauses: 0
  116. Total No. of S's: 3
  117. Total No. of A's: 3
  118. Total No. of O's: 6
  119.  
  120. It seems the lines with a single curly brackets are being treated as lines
  121. with "{O".  What gives?
  122.  
  123. Cheers,
  124. Stuart
  125.  
  126. -- 
  127. Stuart Robinson <Stuart.Robinson@no_spam!anu.edu.au>
  128. The Australian National University
  129. *TO REPLY, REMOVE "no_spam!" FROM E-MAIL ADDRESS GIVEN ABOVE
  130.